#pragma GCC optimize(3)
#pragma GCC optimize(2)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include<bits/stdc++.h>
#define ll long long
#define PB push_back
#define pii pair<int, int>
#define x first
#define y second
#define vct vector
using namespace std;
int vis[5005], n;
char g[5005][5005];
void dfs(int u, int f){
vis[u] = 1;
for(int v = 1; v <= n; v++){
if(g[u][v] == '0') continue;
if(g[v][f] == '1'){
printf("%d %d %d", f, u, v);
exit(0);
}
if(!vis[v]) dfs(v, u);
}
}
int main(){
scanf("%d", &n);
for(int i = 1; i <= n; i++) scanf("%s", g[i] + 1);
for(int i = 1; i <= n; i++)
if(!vis[i]) dfs(i, 0);
cout << -1;
return 0;
}
180C - Letter | 151A - Soft Drinking |
1352A - Sum of Round Numbers | 281A - Word Capitalization |
1646A - Square Counting | 266A - Stones on the Table |
61A - Ultra-Fast Mathematician | 148A - Insomnia cure |
1650A - Deletions of Two Adjacent Letters | 1512A - Spy Detected |
282A - Bit++ | 69A - Young Physicist |
1651A - Playoff | 734A - Anton and Danik |
1300B - Assigning to Classes | 1647A - Madoka and Math Dad |
710A - King Moves | 1131A - Sea Battle |
118A - String Task | 236A - Boy or Girl |
271A - Beautiful Year | 520B - Two Buttons |
231A - Team | 479C - Exams |
1030A - In Search of an Easy Problem | 158A - Next Round |
71A - Way Too Long Words | 160A - Twins |
1A - Theatre Square | 1614B - Divan and a New Project |